/*
 * Copyright Eduardo Aponte 2013
 * aponteeduardo@gmail.com
 */
#include <eyelink.h>
#include "mex.h"

 
INT16 _main( char FARTYPE *msg )
{
    return eyecmd_printf( msg );
    return 1;
}

void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
    mwSize td[2] = {1,1};
    double *status;
    char FARTYPE *msg;

    /* Verify input arguments. */
    if(nrhs != 1 ) {
        mexErrMsgTxt("Incorrect number of inputs.");
    } else if( nlhs > 1 ) {
        mexErrMsgTxt("Too many output arguments.");
    }
           
    if (!mxIsChar(prhs[0]))
        mexErrMsgTxt("msg should be a string.");
   
    msg = mxArrayToString( prhs[0] );
    
    plhs[0] = mxCreateNumericArray( 2, td, mxDOUBLE_CLASS, mxREAL);
    status = mxGetPr(plhs[0]);
    
    *status = (double ) _main( msg );

    mxFree(msg);

    return;
}
